﻿<UserControl x:Class="AutomationMLMapper.Controls.RoleClassLibListControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:AutomationMLMapper.Controls"
             xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
			 xmlns:ConvertersAndTemplateSelectors="clr-namespace:AutomationMLMapper.Controls.ConvertersAndTemplateSelectors"
             xmlns:MarkupExtensions="clr-namespace:AutomationMLMapper.Controls.MarkupExtensions"
			 xmlns:Properties="clr-namespace:AutomationMLMapper.Properties" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
   
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/ListStyle.xaml"/>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/Templates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ConvertersAndTemplateSelectors:BoolToVisibilityConverter FalseValue="Collapsed" x:Key="btvc" />
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid Background="Transparent">   
        
        <ListView IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch"
			 Name="ListOfRoleClassLibraries"
                  VirtualizingStackPanel.IsVirtualizing="True"
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  ScrollViewer.IsDeferredScrollingEnabled="True"
                  Grid.IsSharedSizeScope="True"
			      ItemsSource="{Binding RoleLibsCollection.View}" Margin="0,2,0,0" >

            <ListView.View>
                <GridView>

                    <GridViewColumn Width="Auto" HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{MarkupExtensions:ImageResolution Source=RCLib.ico,Size=24}"></Image>
                                    <TextBlock VerticalAlignment="Center" Margin="5,0,5,0" Text="RoleClassLib"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                        
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Grid Width="Auto"> 
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" SharedSizeGroup="Col1"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto" SharedSizeGroup="Col2"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto" SharedSizeGroup="Col3"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto" SharedSizeGroup="Col4"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Margin="1" Grid.Column="0" Text="{Binding Name}"></TextBlock>
                                    <ribbon:RibbonButton Margin="1" Grid.Column="1" x:Name="DiffButton" Visibility="{Binding IsDifferent, Converter={StaticResource btvc}}"
                                                         ToolTip="Explore the Difference" Command="{Binding ShowRoleLibDifference}"
                                                         SmallImageSource="/AutomationMLMapper;component/Images/diff.png"></ribbon:RibbonButton>
                                    <TextBlock Grid.Column="2"  Margin="1" >
                                        <Run Text="Export"></Run>
                                        <Ellipse x:Name="ExportState" Margin="2,0,0,0" Height="8" Width="8" HorizontalAlignment="Right"  Fill="LimeGreen" StrokeThickness="0.4"></Ellipse>
                                    </TextBlock>
                                    <TextBlock Grid.Column="3"  Margin="1" >
                                        <Run Text="Import"></Run>
                                        <Ellipse x:Name="ImportState" Margin="2,0,0,0" Height="8" Width="8" HorizontalAlignment="Right"  Fill="LimeGreen" StrokeThickness="0.4"></Ellipse>
                                    </TextBlock>
                                </Grid>

                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=HasExportPartner, UpdateSourceTrigger=PropertyChanged}"
                                                 Value="False">
                                        <DataTrigger.Setters>
                                            <Setter Property="Fill" Value="Red" TargetName="ExportState" />
                                        </DataTrigger.Setters>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding HasImportPartner, UpdateSourceTrigger=PropertyChanged}"
                                                 Value="False">
                                        <DataTrigger.Setters>
                                            <Setter Property="Fill" Value="Red" TargetName="ImportState" />
                                        </DataTrigger.Setters>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                                
                            </DataTemplate>
                            
                            
                            
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                   
                </GridView>
            </ListView.View>

            <ListView.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource ListGroupStyle}">
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>
    </Grid>
</UserControl>
